package net.bw.realtime.tmall.mapper;

import net.bw.realtime.tmall.bean.SaleDeviceHourReport;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/*
 * @ Author：liuyawei
 * @ Date：2025-05-28
 */
@Mapper
public interface SaleDeviceHourStatsMapper {

    @Select("SELECT\n" +
            "    toHour(CAST(window_start_time as DATETIME64)) as hour\n" +
            "     ,sum(if(device_type = 'PC', total_amount,0)) as pc_total_amount\n" +
            "     ,sum(if(device_type != 'PC', total_amount,0)) as no_total_amount\n" +
            "FROM jtp_tmall_report.dws_device_distribution_report\n" +
            "WHERE toDate(window_start_time) = #{date}\n" +
            "GROUP BY hour")
    List<SaleDeviceHourReport> selectSaleAmount(String date);

}
